---
category: Math
created: '2023-12-08'
openGraphCover: /og/1-loc/calculate-midpoint-given-range.png
title: Calculate the midpoint of a given range
---

**JavaScript version**

```js midpoint.js
const midpoint = ([from, to]) => (from + to) / 2;
```

**TypeScript version**

```ts midpoint.ts
const midpoint = ([from, to]: [number, number]): number => (from + to) / 2;
```

## See also

-   [Calculate the midpoint between two points](https://phuoc.ng/collection/1-loc/calculate-the-midpoint-between-two-points/)
